<?php
	require_once('../inc/fen_fns.php');
	sec_session_start_ajax();
	$yid = $_GET['yid'];
	
	if ($yid != '0') {
		$yid =  "AND fen_publications.yayin_yili = '".$yid."'";
	} else {
		$yid = "";
	}

?>	

	<script type="text/javascript">

	$(document).ready(function() {
		$(function() {
			$("a").click(function(){

			var value = $(this).attr('value');
		     
			$.ajax({
            	type: 'GET',
            	url: 'reports/users.php?did='+value,
            	data: 'url=www.google.com.tr',	 
            	beforeSend:function(){
            	    // this is where we append a loading image
            	    $('#users').html('<div class="loading"><img src="images/spinner.gif" alt="Loading..." /></div>');
            	  },  
            	success: function(ajaxCevap) {
            		$('#users').html(ajaxCevap);
            	}
            });
		});
		});

	});		

	</script>

	<div id="faculties"></div>
						<table cellspacing="0" cellpadding="0" class="summaryTableMakale">
							<tr id="summaryTableMakaleRowTop">
								<td id="summaryTableMakaleTD1">&nbsp; Bölüm</td>
								<td id="summaryTableMakaleDepartmentsTDblue">Makale</td>
								<td>Kitap Bölümü</td>
								<td id="summaryTableMakaleDepartmentsTDblue">Kitap</td>
							</tr>
	<?php 
							
	
							$query = $_DB->Query("SELECT * from fen_faculty where type = '1' ORDER BY fen_faculty.faculty_name ASC");
							$count = $_DB->GetResultNumber($query);
							$depid = $_DB->GetResultValue($query, "0", "id");

							$makaletoplam = 0;
							$kitapbolumutoplam = 0;
							$kitaptoplam = 0;
							
							for ($i=0; $i<$count; $i++) {
								
								$querymakale = $_DB->Query("SELECT fen_publications.id from fen_publications, fen_members WHERE fen_publications.member_id = fen_members.id AND fen_members.faculty_id = ".$_DB->GetResultValue($query, $i, "id")." AND fen_publications.yayin_tipi = 'Makale' ".$yid);
								$countmakale = $_DB->GetResultNumber($querymakale);
								
								$querykitapbolumu = $_DB->Query("SELECT fen_publications.id from fen_publications, fen_members WHERE fen_publications.member_id = fen_members.id AND fen_members.faculty_id = ".$_DB->GetResultValue($query, $i, "id")." AND fen_publications.yayin_tipi = 'Kitap B√∂l√ºm√º' ".$yid);
								$countkitapbolumu = $_DB->GetResultNumber($querykitapbolumu);
								
								$querykitap = $_DB->Query("SELECT fen_publications.id from fen_publications, fen_members WHERE fen_publications.member_id = fen_members.id AND fen_members.faculty_id = ".$_DB->GetResultValue($query, $i, "id")." AND fen_publications.yayin_tipi = 'Kitap' ".$yid);
								$countkitap = $_DB->GetResultNumber($querykitap);
								
								$makaletoplam = $makaletoplam + $countmakale;
								$kitapbolumutoplam = $kitapbolumutoplam + $countkitapbolumu;
								$kitaptoplam = $kitaptoplam + $countkitap;
				
				
								echo "
									<tr id=\"summaryTableBolumRow1\">
										<td id=\"summaryTableMakaleDepartmentsTD\">&nbsp;<a href=\"reports.php?rid=3&fid=".$_DB->GetResultValue($query, $i, "id")."\" id=\"nocolor\" value=\"".$_DB->GetResultValue($query, $i, "id")."\">".$_DB->GetResultValue($query, $i, "faculty_name")."</a></td>
										<td id=\"summaryTableMakaleDepartmentsTDgrey\">$countmakale</td>
										<td>$countkitapbolumu</td>
										<td id=\"summaryTableMakaleDepartmentsTDgrey\">$countkitap</td>
									</tr>
								";
							}
	?>						
							
							<tr id="summaryTableMakaleRowBottom">
								<td id="summaryTableMakaleTD1">&nbsp; Toplam</td>
								<td id="summaryTableMakaleDepartmentsTDorange"><?php echo $makaletoplam; ?></td>
								<td><?php echo $kitapbolumutoplam; ?></td>
								<td id="summaryTableMakaleDepartmentsTDorange"><?php  echo $kitaptoplam; ?></td>
							</tr>
						</table>